home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / cdity / ModeProSrc.lha / Daemon / OldPatch / BAckdrop.cOLD next >
Text File  |  1998-06-27  |  5KB  |  180 lines

  1. #include "MP.h"
  2. //#include "MPobject.h"
  3. #include <proto/datatypes.h>
  4. #include <datatypes/datatypesclass.h>
  5. #include <datatypes/datatypes.h>
  6. #include <datatypes/pictureclass.h>
  7. #include "imagebackfill.h"
  8.  
  9. #define MPHOOK_OK   0
  10. #define MPHOOK_WARN 1
  11. #define MPHOOK_FAIL 2
  12.  
  13. extern BOOL    V39;
  14.  
  15. void FreeBackdrop(struct Backdrop *B);
  16.  
  17. struct Backdrop
  18. {
  19.   struct Node bd_Node;
  20.   struct Screen *bd_Screen;
  21.   struct Window *bd_Window;
  22.   BOOL   bd_Loaded;
  23.   struct BackFillOptions  bd_BFOptions;
  24.   struct BackFillInfo     bd_BFInfo;
  25. };
  26.  
  27. struct List BackdropList;
  28.  
  29. LONG AddBackdrop(struct Screen *Scr, struct DefaultNode *DN)
  30. {
  31.   struct Backdrop *b;
  32. //  ULONG dtwidth,dtheight,dtw,dth,swidth,sheight,wleft,wtop,gid;
  33. //  struct FrameInfo *fi;
  34.   
  35.  
  36.   if(Scr && DN && V39)
  37.   {
  38.     if((DN->BackdropFlags & BF_ON) && DN->BackdropFile && DataTypesBase)
  39.     {
  40.       
  41.       
  42.       if(b=AllocVec(sizeof(struct Backdrop),MEMF_CLEAR|MEMF_PUBLIC))
  43.       {
  44.         b->bd_Screen=Scr;
  45.         
  46.         b->bd_BFOptions.MaxCopyWidth=
  47.         b->bd_BFOptions.MaxCopyWidth=320;
  48.         b->bd_BFOptions.CenterX=
  49.         b->bd_BFOptions.CenterY=(DN->BackdropFlags & BF_CENTER);
  50.         b->bd_BFOptions.OffsetX=0;
  51.         b->bd_BFOptions.OffsetY=0;
  52.         b->bd_BFOptions.OffsetTitleY=0;
  53.   
  54.           
  55.         if(LoadBackgroundImage(&b->bd_BFInfo,DN->BackdropFile,Scr,&b->bd_BFOptions))
  56.         {
  57.           b->bd_Loaded=1;
  58.           if(b->bd_Window=OpenWindowTags(0,WA_CustomScreen, Scr,
  59.                                  WA_Left        ,0,
  60.                                      WA_Top         ,0,
  61.                                      WA_Width       ,Scr->Width,
  62.                                      WA_Height      ,Scr->Height,
  63.                                      WA_Flags       ,WFLG_BACKDROP|WFLG_BORDERLESS|WFLG_SIMPLE_REFRESH|WFLG_NOCAREREFRESH,
  64.                                      WA_CustomScreen,Scr,
  65.                                      WA_BackFill    ,&b->bd_BFInfo,
  66.           
  67.        /*                                    WA_Top         , wtop,
  68.                                            WA_Left        , wleft,
  69.                                            WA_Width       , dtwidth,
  70.                                            WA_Height      , dtheight,
  71.                                            WA_AutoAdjust  , 1,
  72.                                         //   WA_Backdrop    , 1,
  73.                                         //   WA_Borderless  , 0,
  74.                                            WA_SimpleRefresh,1,*/
  75.                                            TAG_DONE))
  76.           {
  77.               AddHead(&BackdropList,(struct Node *)b);
  78.            //   AddDTObject(b->bd_Window,0,b->bd_DTObject,-1);
  79.            //   RefreshDTObjectA(b->bd_DTObject,b->bd_Window,0,0);
  80.               return(MPHOOK_OK);
  81.           }
  82.         }
  83.         FreeBackdrop(b);
  84.       }
  85.     }
  86.   }
  87. }
  88.  
  89. void RemoveBackdrop(struct Screen *Scr)
  90. {
  91.   struct Backdrop *b;
  92.   
  93.   b=(struct Backdrop *)BackdropList.lh_Head;
  94.   
  95.   while(b->bd_Node.ln_Succ)
  96.   {
  97.     if(b->bd_Screen==Scr)
  98.     {
  99.       struct Backdrop *b2;
  100.       
  101.       b2=(struct Backdrop *)b->bd_Node.ln_Succ;
  102.       
  103.       Remove((struct Node *)b);
  104.       FreeBackdrop(b);
  105.       
  106.       b=b2;
  107.     }
  108.     else
  109.     {
  110.       b=(struct Backdrop *)b->bd_Node.ln_Succ;
  111.     }
  112.   }
  113. }
  114.  
  115.  
  116. void FreeBackdrop(struct Backdrop *B)
  117. {
  118.   if(B)
  119.   {
  120.     if(B->bd_Loaded)
  121.     {
  122.       if(B->bd_Window)
  123.       {
  124.         CloseWindow(B->bd_Window);
  125.       }
  126.       UnloadBackgroundImage(&B->bd_BFInfo);
  127.     }
  128.     FreeVec(B);
  129.   }
  130. }
  131.  
  132.  
  133.  
  134.  
  135.  
  136.       /* 
  137.     if(b->bd_DTObject=NewDTObject(DN->BackdropFile,
  138.                                      DTA_GroupID,       GID_PICTURE,
  139.                                      DTA_SourceType,    DTST_FILE,
  140.                                      DTA_Immediate,     1,
  141.                                      //PDTA_Remap   ,TRUE,
  142.                                      //PDTA_Screen  ,Scr,
  143.                                      DTA_TextAttr,      Scr->Font,
  144.                                      GA_ID,             b,
  145.                                      TAG_DONE))
  146.       {
  147.         swidth=dtwidth    =Scr->Width;
  148.         sheight=dtheight  =Scr->Height-Scr->BarHeight+Scr->BarVBorder;
  149.         
  150.         GetDTAttrs(b->bd_DTObject, DTA_NominalHoriz,      &dtwidth,
  151.                                    DTA_NominalVert,       &dtheight,
  152.                                    DTA_GroupID,           &gid,
  153.                                    DTA_FrameInfo,         &fi,
  154.                                    TAG_DONE);
  155.         
  156.         
  157.  
  158.         dtwidth=fi->fri_Dimensions.Width;
  159.         dtheight=fi->fri_Dimensions.Height;
  160.         
  161.         dtwidth =min(swidth,dtwidth);
  162.         dtheight=min(sheight,dtheight);
  163.  
  164.         dtwidth =max(50,dtwidth);
  165.         dtheight=max(50,dtheight);
  166.  
  167.         
  168.         
  169.         wleft =(swidth-dtwidth)/2;
  170.         wleft =max(0,wleft);
  171.         
  172.         wtop  =(sheight-dtheight)/2;
  173.         wtop  =max(0,wtop);
  174.         
  175.         SetDTAttrs(b->bd_DTObject, 0,0,
  176.                                    GA_Width,      dtwidth,
  177.                                    GA_Height,     dtheight,
  178.                                    TAG_DONE);
  179.         
  180.       */